﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DAL;

public partial class Form_DangKy : System.Web.UI.Page
{
    GetData getData;
    protected void Page_Load(object sender, EventArgs e)
    {
        getData = new GetData();
    }

    public void LoadData()
    {

    }

    protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
    {
        KhachHang kh = new KhachHang();
        kh = DangKyThanhVien();
        if (kh != null)
        {
            Response.Redirect("DangNhap.aspx");
        }
    }

    public KhachHang DangKyThanhVien()
    {
        KhachHang kh = new KhachHang();
        kh.Diachi = txtDiaChi.Text.Trim();
        kh.DTDD = txtDTDD.Text.Trim();
        kh.Email = txtEmail.Text.Trim();        
        if (txtMatKhau.Text.Trim() == txtXacNhanMatKhau.Text.Trim())
        {
            mahoavb.Mahoa mh = new mahoavb.Mahoa();
            string _Pass = mh.Encode(txtMatKhau.Text.Trim(), 9);
            kh.PassWork = _Pass;
        }
        else
        {
            lblCheck.Text = "Mật khẩu không đúng, bạn vui lòng nhập lại!";
        }
        kh.Quan = txtQuan.Text.Trim();
        kh.QuocGia = txtQuocGia.Text.Trim();
        kh.TenKH = txtHoTen.Text.Trim();
        kh.ThanhPho = txtTP.Text.Trim();
        kh.UserName = txtTenTK.Text.Trim();
        return  getData.TaoMoiKhachHang(kh);        
    }

    protected void ImageButton2_Click(object sender, ImageClickEventArgs e)
    {
        txtHoTen.Text = "";
        txtDiaChi.Text = "";
        txtQuocGia.Text = "";
        txtTP.Text = "";
        txtQuan.Text = "";
        txtDT.Text = "";
        txtDTDD.Text = "";
        txtEmail.Text = "";
        txtTenTK.Text = "";
        txtMatKhau.Text = "";
        txtXacNhanMatKhau.Text = "";
    }
}